<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        window.onload=function(){
            var tab=document.createElement("table");
            tab.width=400;
            tab.border=1;
            //添加标题
            var caption=document.createElement("caption");
            caption.innerHTML="表格标题";
            tab.appendChild(caption);
            //添加tohead
            var th=document.createElement("thead");
            var thtr=document.createElement("tr");
            var thtrtd1=document.createElement("td");
            thtrtd1.innerHTML="名字";
            thtr.appendChild(thtrtd1);
            th.appendChild(thtrtd1);
            var thtrtd2=document.createElement("td");
            thtrtd2.innerHTML="年龄";
            thtr.appendChild(thtrtd2)
            th.appendChild(thtrtd2);
            tab.appendChild(th);

            tab.appendChild(th);

            document.body.appendChild(tab);
        }
    </script>
</head>
<body>

</body>
</html>